package com.ruoyi.materialCuttingPlan.service.impl;

import java.util.List;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.materialCuttingPlan.mapper.McpMaterialResultsMapper;
import com.ruoyi.materialCuttingPlan.domain.McpMaterialResults;
import com.ruoyi.materialCuttingPlan.service.IMcpMaterialResultsService;

/**
 * 门窗用料计算结果Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-07-04
 */
@Service
public class McpMaterialResultsServiceImpl implements IMcpMaterialResultsService 
{
    @Autowired
    private McpMaterialResultsMapper mcpMaterialResultsMapper;

    /**
     * 查询门窗用料计算结果
     * 
     * @param id 门窗用料计算结果主键
     * @return 门窗用料计算结果
     */
    @Override
    public McpMaterialResults selectMcpMaterialResultsById(Long id)
    {
        return mcpMaterialResultsMapper.selectMcpMaterialResultsById(id);
    }

    /**
     * 查询门窗用料计算结果列表
     * 
     * @param mcpMaterialResults 门窗用料计算结果
     * @return 门窗用料计算结果
     */
    @Override
//    @DataScope(userAlias = "u")
    public List<McpMaterialResults> selectMcpMaterialResultsList(McpMaterialResults mcpMaterialResults)
    {
        return mcpMaterialResultsMapper.selectMcpMaterialResultsList(mcpMaterialResults);
    }

    /**
     * 新增门窗用料计算结果
     * 
     * @param mcpMaterialResults 门窗用料计算结果
     * @return 结果
     */
    @Override
    public int insertMcpMaterialResults(McpMaterialResults mcpMaterialResults)
    {
        mcpMaterialResults.setCreateTime(DateUtils.getNowDate());
        mcpMaterialResults.setCreateBy(SecurityUtils.getUsername());
        mcpMaterialResults.setCreateById(SecurityUtils.getUserId());
        return mcpMaterialResultsMapper.insertMcpMaterialResults(mcpMaterialResults);
    }

    /**
     * 修改门窗用料计算结果
     * 
     * @param mcpMaterialResults 门窗用料计算结果
     * @return 结果
     */
    @Override
    public int updateMcpMaterialResults(McpMaterialResults mcpMaterialResults)
    {
        mcpMaterialResults.setUpdateTime(DateUtils.getNowDate());
        mcpMaterialResults.setUpdateBy(SecurityUtils.getUsername());
        mcpMaterialResults.setUpdateById(SecurityUtils.getUserId());
        return mcpMaterialResultsMapper.updateMcpMaterialResults(mcpMaterialResults);
    }

    /**
     * 批量删除门窗用料计算结果
     * 
     * @param ids 需要删除的门窗用料计算结果主键
     * @return 结果
     */
    @Override
    public int deleteMcpMaterialResultsByIds(Long[] ids)
    {
        return mcpMaterialResultsMapper.deleteMcpMaterialResultsByIds(ids);
    }

    /**
     * 删除门窗用料计算结果信息
     * 
     * @param id 门窗用料计算结果主键
     * @return 结果
     */
    @Override
    public int deleteMcpMaterialResultsById(Long id)
    {
        return mcpMaterialResultsMapper.deleteMcpMaterialResultsById(id);
    }

    @Override
    public int deleteMcpMaterialResultsByWindowId(Long id) {
        return mcpMaterialResultsMapper.deleteMcpMaterialResultsByWindowId(id);
    }

    @Override
    public int deleteMcpMaterialResultsByWindowIds(Long[] ids) {
        return mcpMaterialResultsMapper.deleteMcpMaterialResultsByWindowIds(ids);
    }
}
